package com.example.demo;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Description
 * @Author
 * @Date 2019/8/22 20:36
 **/
public class ThreadPoolFactory implements ThreadFactory
{
    private AtomicInteger threadNumber = new AtomicInteger(1);

    private String prefix = null;

    public ThreadPoolFactory(String prefix)
    {
        super();
        this.prefix = prefix;
    }

    public String getPrefix()
    {
        return prefix;
    }

    public void setPrefix(String prefix)
    {
        this.prefix = prefix;
    }

    public Thread newThread(Runnable r)
    {
        return new Thread(r,prefix + threadNumber.getAndIncrement());
    }

}
